package splug.cjk;

import java.util.ArrayList;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class MyWriting extends ListActivity implements OnItemClickListener{
	
	private String id;
	private ArrayList<String> content = new ArrayList<String>();
	private ArrayAdapter<String> m_adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_writing);
		setTitle("내가 쓴 글 확인");
		
		Bundle b = this.getIntent().getExtras();
		id = b.getString("ID");
		
		content.add("자유 게시판");
		content.add("태워드립니다 게시판");
		content.add("태워주세요 게시판");
		
		Button back = (Button) findViewById(R.id.btn_mywriting_back);
		
		//뒤로가기 버튼 이벤트 추가
		back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		m_adapter = new ArrayAdapter<String>(MyWriting.this, android.R.layout.simple_list_item_1, content);
		setListAdapter(m_adapter);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		
	}

	/**
	 * 0번 자유게시판
	 * 1번 태워드립니다
	 * 2번 태워주세요
	 */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long aa) {
		super.onListItemClick(l, v, position, aa);
		Intent intent = null;
		Bundle b = new Bundle();
		b.putString("ID", id);
		
		switch(position){
		case 0:
			intent = new Intent(MyWriting.this, MyWritingTab1.class);
			intent.putExtras(b);
			startActivity(intent);
			break;
		case 1:
			intent = new Intent(MyWriting.this, MyWritingTab2.class);
			intent.putExtras(b);
			startActivity(intent);
			break;
		case 2:
			intent = new Intent(MyWriting.this, MyWritingTab3.class);
			intent.putExtras(b);
			startActivity(intent);
			break;
		}
	}
}
